package hn.cch.pattern.factory;


// 产品接口
interface Product {
    void use();
}

// 具体产品A
class ProductA implements Product {
    @Override
    public void use() {
        System.out.println("Using Product A");
    }
}

// 具体产品B
class ProductB implements Product {
    @Override
    public void use() {
        System.out.println("Using Product B");
    }
}

// 工厂接口
interface Factory {
    Product createProduct();
}

// 具体工厂A
class FactoryA implements Factory {
    @Override
    public Product createProduct() {
        return new ProductA();
    }
}

// 具体工厂B
class FactoryB implements Factory {
    @Override
    public Product createProduct() {
        return new ProductB();
    }
}


public class FactoryPattern {
    public static void main(String[] args) {
        Factory factory = new FactoryA();
        Product product = factory.createProduct();
        product.use();  // 输出: Using Product A
    }
}
